<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
/* 
 function registerForm(){
	var	url = "/${initParam.context_root}/ViewForRegisterAdminBoard.do";
	window.open(url, "registerForm", "width=850px, height=550px, menubar=no, status=yes, realzable=no, location=no, scrollbars=yes, toolbar=no, resizable=yes");
} 
*/
function searchBoard(){
	var objType = document.getElementById("boardType");
	var selectedType = objType.selectedIndex;		//selectedIndex 메소드는 해당 option index번호 
	//var selectedTextType = objType.options[selectedType].value;	
	//var boardType = selectedTextType.substr(selectedTextType.lastIndexOf(',')+1);	//,(콤마) 이후로 String
	if(selectedType==0){	//인덱스가 0이면 다시 선택하도록 리턴
		alert("게시판 종류를 선택하세요.");
		return;
	}
	
	var objName = document.getElementById("boardSearchSelector");
	var selectedName = objName.selectedIndex;		 
	//var selectedTextName = objName.options[selectedName].value;	
	//var second = selectedTextName.substr(selectedTextType.lastIndexOf(',')+1);		//,(콤마) 이후로 String
	if(selectedName==0){		//인덱스가 0이면 다시 선택하도록 리턴
		alert("선택 후 검색하세요.");
		return;
	}
	var url = "/${initParam.context_root }/searchBoard.do";
	$("#searchForm").attr({"action":url, "method":"post"}).submit();
}

function removeChk(i){
	var url = '/${initParam.context_root }/removeAdminBoard.do?boardNo='+i;
	var flag = window.confirm("정말 삭제하시겠습니까?");
	if(flag){
		$("#removeBoard").attr({"action":url,"method":"post"}).submit();
	}
	else{
		return;
	}
}
</script>
<title>관리자용 화면</title>
</head>
<body>
<c:if test="${not empty message }"><font color="red" ><b>${message }</b></font></c:if>
<br>
<form id="searchForm" >
<div align="right" style="padding-right: 40px">
	<select name="boardType" id="boardType">
		<option value="0">게시판 종류</option>
		<option value="일반형">일반형</option>
		<option value="자료실형">자료실형</option>
		<option value="QnA형">QnA형</option>
		<option value="FAQ형">FAQ형</option>
		<option value="이미지형">이미지형</option>
	</select>&nbsp;
	<select name="boardSearchSelector" id="boardSearchSelector">
		<option value="0">선택하세요.</option>
		<option value="boardName">게시판명</option>
		<option value="adminName">등록자</option>
	</select>&nbsp;
	<input type="text" name="boardSearchText" maxlength="20">
	<a href="javascript:searchBoard();">[검색]</a></div>
</form>

	<br>
	<div align="right">
		<a href="/${initParam.context_root}/typeNine.do" >[새로고침]</a>&nbsp;&nbsp;
		<a href="/${initParam.context_root}/ViewForRegisterAdminBoard.do" >[등록]</a>
	</div>
<table border="1" cellpadding="4px" cellspacing=0 width="1100px">
	<thead>
		<tr bgcolor="lightgray">
			<th>게시판 명</th><th width="110px">게시판종류</th><th>카테고리</th><th width="130px">등록자</th><th width="160px">등록일시</th>
			<th width="60px">삭제</th>
		</tr>
	</thead>
	<tbody>
	<c:choose>
		<c:when test="${not empty requestScope.listAdminBoard  }">
			<c:forEach items="${requestScope.listAdminBoard.list}" var="boardVO" varStatus="i">
			<tr>
				<td><a href="/${initParam.context_root }/selectOneAdminBoard.do?boardNo=${boardVO.boardNo }">${boardVO.boardName }</a></td>
				<td align="center">${boardVO.boardType }</td>
				<td>${boardVO.category }</td>
				<td>${boardVO.adminName }</td>
				<td>${boardVO.registerDate }</td>
				<td align="center"><form id="removeBoard"><input type="button" value="삭제" onclick="removeChk(${boardVO.boardNo })"></form></td>
			</tr>
		</c:forEach>
		</c:when>
		<c:otherwise>
		<tr align="center"><td colspan="6">
			<font color="blue" ><b>${message }<br>[새로고침]을 눌러주세요.</b></font>
			</td>
		<tr>
		</c:otherwise>
	</c:choose>
	</tbody>
</table>
<br>
<center>
<table cellpadding=12 cellspacing=0 width=1100px>
		<tr><td>
		<c:choose>
		<c:when test="${ requestScope.listAdminBoard.pageDTO.previousPageGroup }"> 
			<a href="/${initParam.context_root }/typeNine.do?page=${requestScope.listAdminBoard.pageDTO.currentPage -1}">◀</a>
		</c:when>
		<c:otherwise>◀</c:otherwise>
		</c:choose>
			<c:forEach begin="${requestScope.listAdminBoard.pageDTO.startPageOfPageGroup }" end="${requestScope.listAdminBoard.pageDTO.endPageOfPageGroup }" step="1" var="i">
				&nbsp;<font color=orange><B><a href="/${initParam.context_root }/typeNine.do?page=${i }">${i }</a></B></font>&nbsp;&nbsp;	
			</c:forEach>
		<c:choose >
		<c:when test="${ requestScope.listAdminBoard.pageDTO.nextPageGroup }"> 
			<a href="/${initParam.context_root }/typeNine.do?page=${requestScope.listAdminBoard.pageDTO.currentPage +1 }">▶</a>
		</c:when>
		<c:otherwise>▶</c:otherwise>
		</c:choose>
		</td></tr>
</table>
</center>

</body>
</html>